package jnBase.components
{
	import laya.events.EventDispatcher;
	import laya.utils.Browser;
	
	public class GetRequest extends EventDispatcher
	{
		private static var _ins:GetRequest;
		public static var SEND_REQUEST_RESULT:String="get_request_result";
		public function GetRequest()
		{
			super();
		}
		public static function getRequests():Object{
			
			var url:String = Browser.window.location.search; //获取url中含"?"符后的字串
			
			var theRequest:Object = new Object();
			
			if (url.indexOf("?") != -1) {
				
				var str:String = url.substr(1);
				
				var strs:Array = str.split("&");
				
				for(var i:int = 0; i < strs.length; i ++) {
					
					theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
					
				}
			}
			return theRequest;
		}
		/*public static function sendRequest(url:String, caller:*,comlistener:Function,data:*=null, method:String="get", responseType:String="text",headers:Array=null):void{
			var xhr:HttpRequest = new Laya.HttpRequest();
			xhr.http.timeout = 10000;//设置超时时间；
			xhr.once(Event.COMPLETE,caller,comlistener);
			xhr.once(Event.ERROR,null,errorHandler);
			xhr.on(Event.PROGRESS,null,processHandler);
			xhr.send(url,data,method,responseType,headers);
		}
		private static function processHandler(data:*):void
		{
			// TODO Auto Generated method stub
		}
		
		private static function errorHandler(data:*):void
		{
			// TODO Auto Generated method stub
			trace("http请求错误："+data);
		}*/
		
		public static function getInstance():GetRequest
		{
			// TODO Auto Generated method stub
			_ins=new GetRequest();
			return _ins;
		}
	}
}